package com.ssyc.student.activity;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.ssyc.common.base.BaseActivity;
import com.ssyc.common.view.TypeTextView;
import com.ssyc.student.R;

/**
 * 领取宠物界面1
 * Created by Kevin on 2018/4/18.
 */

@Route(path = "/student/studentgetpetone")
public class StudentGetpetOneActivity extends BaseActivity implements View.OnClickListener {

    //确认按钮
    private TextView tv_commit;

    //显示的文字
    private TypeTextView tvChoosePet;


    @Override
    protected boolean isNeedShowTitle() {
        return false;
    }

    @Override
    protected String setTitleText() {
        return null;
    }

    @Override
    protected int getContentLayout() {

        return R.layout.student_activity_getpet_one;
    }

    @Override
    protected void init() {
        showContent();

        //初始化视图
        initview();

    }

    /**
     * 初始化视图的方法
     */
    private void initview() {

        tvChoosePet = findViewById(R.id.tv_choose_pet);
        tvChoosePet.start(getResources().getString(R.string.st_choose_pt_one));
        //设置打印完成的监听事件
        tvChoosePet.setOnTypeViewListener(new TypeTextView.OnTypeViewListener() {
            @Override
            public void onTypeStart() {

            }

            @Override
            public void onTypeOver() {
                if (null != tv_commit) {
                    tv_commit.setVisibility(View.VISIBLE);
                }
            }
        });

        tv_commit = findViewById(R.id.tv_commit);
        tv_commit.setVisibility(View.INVISIBLE);
        tv_commit.setOnClickListener(this);

    }


    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.tv_commit) {
            //跳转页面
            Intent intent = new Intent(this, StudentChooserPetActivity.class);
            startActivity(intent);
            finish();
        }
    }

    /**
     * 生命周期中取消打字机效果
     */
    @Override
    protected void onDestroy() {
        if (null != tvChoosePet) {
            tvChoosePet.stop();
        }
        super.onDestroy();
    }
}
